﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.ServiceModel;
using System.Text;

namespace NotifierService.Service
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)]
    public abstract class ServiceBase : IServiceBase
    {

        internal void InternalProcessVoiceBuffer(byte[] buffer, int length)
        {
            ProcessIncomingVoiceStream(buffer, length);
        }

        internal void InternalBroadcastStarted()
        {
            OnBroadcastServiceStarted();
        }

        internal void InternalBroadcastStopped()
        {
            OnBroadcastServiceStopped();
        }

        protected abstract void ProcessIncomingVoiceStream(byte[] buffer, int length);

        protected virtual void OnBroadcastServiceStarted() { }

        protected virtual void OnBroadcastServiceStopped() { }

        public abstract IPAddress GetIPAddress();
        public abstract IPEndPoint GetClientEndpoint();
        public abstract bool Authenticate(string name, string password);
        public abstract bool PlayAudio(AudioType type);
        public abstract RealtimeBroadcastServiceData StartRealtimeBroadcast();
        public abstract bool StopRealtimeBroadcast();
        public abstract void Close();
    }
}
